package com.songxh.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * Description:
 * Created by xiangheng.song on 2018/5/5 15:44.
 */

@WebListener
public class ApplicationListener implements ServletContextListener {

    private static final Logger logger = LoggerFactory.getLogger(ApplicationListener.class);

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        logger.info(">>> application starting");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        logger.info(">>> start destroy application context");

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            logger.info(">>> application context destroy interrupted");
            e.printStackTrace();
        }

        logger.info(">>> application context destroyed");
    }
}
